package com.chilly.annotation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.HashSet;

/**
 * Created by Chilly Cui on 2020/9/25.
 */
public class RegionValidator implements ConstraintValidator<Region, String> {
    public void initialize(Region constraint) {
    }

    public boolean isValid(String value, ConstraintValidatorContext context) {
        HashSet<Object> regions = new HashSet<>();
        regions.add("China");
        regions.add("China-Taiwan");
        regions.add("China-HongKong");
        return regions.contains(value);
    }
}
